﻿Imports DTO
Imports System.Data.SqlClient

Public Class ChuyenKhoDAO
    'HuyBinh
    Public Shared Function ThemPhieuChuyenKho(phieuCK As ChuyenKhoDTO) As String
        Dim cn As SqlConnection = CKetNoi.Connect

        Dim cmd As New SqlCommand
        cmd.CommandText = "usp_ThemPhieuChuyenKho"
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Connection = cn
        cn.Open()
        Dim para As SqlParameter
        para = New SqlParameter("@MaNVGui", SqlDbType.VarChar, 7)
        para.Direction = ParameterDirection.Input
        para.Value = phieuCK.MaNhanVienGui
        cmd.Parameters.Add(para)

        para = New SqlParameter("@MaNVNhan", SqlDbType.VarChar, 7)
        para.Direction = ParameterDirection.Input
        para.Value = phieuCK.MaNhanVienNhan
        cmd.Parameters.Add(para)

        para = New SqlParameter("@Ngay", SqlDbType.Date)
        para.Direction = ParameterDirection.Input
        para.Value = phieuCK.Ngay
        cmd.Parameters.Add(para)

        para = New SqlParameter("@GhiChu", SqlDbType.NText)
        para.Direction = ParameterDirection.Input
        para.Value = phieuCK.GhiChu
        cmd.Parameters.Add(para)

        para = New SqlParameter("@ThanhTien", SqlDbType.Float)
        para.Direction = ParameterDirection.Input
        para.Value = phieuCK.ThanhTien
        cmd.Parameters.Add(para)

        para = New SqlParameter("@MaPhieuCK", SqlDbType.VarChar, 7)
        para.Direction = ParameterDirection.Output
        cmd.Parameters.Add(para)

        cmd.ExecuteNonQuery()
        cn.Close()
        Dim maPhieuCK As String = cmd.Parameters("@MaPhieuCK").Value.ToString
        Return maPhieuCK
    End Function
End Class
